{-- ======================================================================== -}

module Main where

import System.Environment
import CalcProbs
import NumParser

main = do args <- getArgs;
          let poolIn = getTheArg toInt args 0 1
          let winsIn = getTheArg toInt args 1 2
          let sidesIn = getTheArg toInt args 2 6
          let pools = [0..poolIn]
          let results = processSet calcProbOne pools winsIn sidesIn
          let response = zip pools results
          putStrLn ("Pool:  " ++ show poolIn)
          putStrLn ("Wins:  " ++ show winsIn)
          putStrLn ("Sides: " ++ show sidesIn)
          putStrLn ("All:   " ++ show (calcProbAll poolIn winsIn sidesIn))
          putStrLn ("At least one:")
          mapM_ print response

getTheArg :: (t1 -> t -> t) -> [t1] -> Int -> t -> t
getTheArg func as b c
  | length as > b = func (as!!b) c
  | otherwise = c

processSet func as b c
  | length as > 0 = (func (head as) b c) : (processSet func (tail as) b c)
  | otherwise = []
